package com.borimi.demo.gen;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import lombok.Data;

import java.util.Collections;


public class CodeGenerator {
    public static void main(String[] args) {

        FastAutoGenerator.create(
                        "jdbc:mysql://192.168.1.183:3306/blm_activity?useUnicode=true&characterEncoding=utf8",
                        "pn", "mSw3GZd7KmJ4nxJe")
                .globalConfig(builder -> {
                    builder.author("lzj")
                            .outputDir(System.getProperty("user.dir") + "/src/main/java");
                })
                .templateEngine(new FreemarkerTemplateEngine())
                .packageConfig(builder -> {
                    builder.parent("com/blm/api/activity/domain/domain2")
                            .pathInfo(Collections.singletonMap(
                                    OutputFile.xml,
                                    System.getProperty("user.dir") + "/src/main/resources/mapper"
                            ));
                })
                .strategyConfig(builder -> {
                    builder.addInclude("platform_activity") // 要生成的表
                            .entityBuilder().enableLombok()
                            .mapperBuilder().enableBaseResultMap().enableBaseColumnList();
                })
                .injectionConfig(consumer -> {
                    // 自定义文件输出
                    consumer.customFile(Collections.singletonMap("vo.java",
                            "/templates/vo.java.ftl")); // 模板路径（resources目录下）
                    consumer.customFile(Collections.singletonMap("queryvo.java",
                            "/templates/queryvo.java.ftl"));
                })
                .execute();
        //CustomGenerator.generateVoAndQueryVo("UserSignInLog", "com.example.system.entity");
    }

}